﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.Record;
using TyMES.Model;

namespace TyMES.ViewModel.Record.PersonLayOffRecordVMs
{
    public partial class PersonLayOffRecordListVM : BasePagedListVM<PersonLayOffRecord_View, PersonLayOffRecordSearcher>
    {
        
        protected override IEnumerable<IGridColumn<PersonLayOffRecord_View>> InitGridHeader()
        {
            return new List<GridColumn<PersonLayOffRecord_View>>{
                
                this.MakeGridHeader(x => x.PersonLayOffRecord_PersonCode).SetTitle(@Localizer["Page.员工工号"].Value),
                this.MakeGridHeader(x => x.PersonLayOffRecord_PersonName).SetTitle(@Localizer["Page.员工姓名"].Value),
                this.MakeGridHeader(x => x.PersonLayOffRecord_Opertion).SetTitle(@Localizer["Page.员工操作"].Value),
                this.MakeGridHeader(x => x.PersonLayOffRecord_OperatonTime).SetTitle(@Localizer["_Admin.ActionTime"].Value),
                this.MakeGridHeader(x => x.PersonLayOffRecord_CreateTime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.PersonLayOffRecord_UpdateTime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.PersonLayOffRecord_CreateBy).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.PersonLayOffRecord_UpdateBy).SetTitle(@Localizer["_Admin.UpdateBy"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<PersonLayOffRecord_View> GetSearchQuery()
        {
            var query = DC.Set<PersonLayOffRecord>()
                
                .CheckContain(Searcher.PersonCode, x=>x.PersonCode)
                .CheckContain(Searcher.PersonName, x=>x.PersonName)
                .CheckContain(Searcher.Opertion, x=>x.Opertion)
                .CheckContain(Searcher.OperatonTime, x=>x.OperatonTime)
                .CheckBetween(Searcher.CreateTime?.GetStartTime(), Searcher.CreateTime?.GetEndTime(), x => x.CreateTime, includeMax: false)
                .CheckBetween(Searcher.UpdateTime?.GetStartTime(), Searcher.UpdateTime?.GetEndTime(), x => x.UpdateTime, includeMax: false)
                .CheckContain(Searcher.CreateBy, x=>x.CreateBy)
                .CheckContain(Searcher.UpdateBy, x=>x.UpdateBy)
                .Select(x => new PersonLayOffRecord_View
                {
				    ID = x.ID,
                    
                    PersonLayOffRecord_PersonCode = x.PersonCode,
                    PersonLayOffRecord_PersonName = x.PersonName,
                    PersonLayOffRecord_Opertion = x.Opertion,
                    PersonLayOffRecord_OperatonTime = x.OperatonTime,
                    PersonLayOffRecord_CreateTime = x.CreateTime,
                    PersonLayOffRecord_UpdateTime = x.UpdateTime,
                    PersonLayOffRecord_CreateBy = x.CreateBy,
                    PersonLayOffRecord_UpdateBy = x.UpdateBy,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class PersonLayOffRecord_View: PersonLayOffRecord
    {
        
        public string PersonLayOffRecord_PersonCode { get; set; }
        public string PersonLayOffRecord_PersonName { get; set; }
        public string PersonLayOffRecord_Opertion { get; set; }
        public string PersonLayOffRecord_OperatonTime { get; set; }
        public DateTime? PersonLayOffRecord_CreateTime { get; set; }
        public DateTime? PersonLayOffRecord_UpdateTime { get; set; }
        public string PersonLayOffRecord_CreateBy { get; set; }
        public string PersonLayOffRecord_UpdateBy { get; set; }

    }

}